﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.CRM.Component.Common;
using TRPOP.CRM.Component.Business;
using TRPOP.CRM.Component.Model;
using TRPOP.Common;

namespace TRPOP.CRM.Web
{
    /// <summary>
    /// 保存、新增客户类型信息
    /// </summary>
    public partial class CompanyCategory_save : BaseAdmin
    {
        #region 权限限制
        protected override void SubPageInit()
        {
            base.m_oCurrentPermissionKey = "Sys_CompanyCategory";
        }
        #endregion

        #region 页面变量
        private CompanyCategoryInfo m_CompanyCategoryInfo = new CompanyCategoryInfo();
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (RequestHelper.RequestInt("id") > 0)
                {
                    //BindData();
                }
            }  
        }

        //修改、新增CompanyCategory
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (ViewState["CompanyCategory"] != null)
            {
                //修改
                m_CompanyCategoryInfo = ViewState["CompanyCategory"] as CompanyCategoryInfo;
            }
            else
            {
                //新增
                m_CompanyCategoryInfo.bIsDelete = false;
            }
            m_CompanyCategoryInfo.nvcCompanyCategoryName = nvcCompanyCategoryName.Text.HtmlEncode();
            m_CompanyCategoryInfo.nvcDiscription = txtDescription.Text.HtmlEncode();

            //保存
            if (TRPOP.CRM.Component.Business.BaseManage.SaveCompanyCategoryInfo(m_CompanyCategoryInfo))
            {
                Alert("保存成功!", "CompanyCategory_list.aspx");
            }
            else
            {
                Alert("保存失败!");
            }
        }
        #endregion 

        #region 页面方法
        protected void BindData()
        {
            m_CompanyCategoryInfo = TRPOP.CRM.Component.Business.BaseManage.GetCompanyCategoryInfoByID(RequestHelper.RequestInt("id"));

            if (m_CompanyCategoryInfo != null)
            {
                ViewState["m_CompanyCategory"] = m_CompanyCategoryInfo;
                nvcCompanyCategoryName.Text = m_CompanyCategoryInfo.nvcCompanyCategoryName.HtmlDecode();
                this.txtDescription.Text = m_CompanyCategoryInfo.nvcDiscription.HtmlDecode();
            }
        }
        #endregion
    }
}